<?php

class Plugin_lastposts implements Plugin {
	public static function getName(){
		return 'Last posts';
	}
	public static function getVersion(){
		return '0.1';
	}
	public static function getDescription(){
		return 'Get last 5 posts';
	}
	public static function getHasAdmin(){
		return false;
	}
	public static function onActivate(){
		
	}
	public static function onDeactivate(){
		
	}
	public static function run(){
		$news = Mysql::getInstance()->select('news','*');
		
		$all = '';
		foreach ($news as $p){
			$text = strip_tags(stripslashes($p['sstory']));
			
			$text = substr($text,0,strripos(substr($text,0,500),'.'));
			  
			$all .= '<strong>'.stripslashes($p['title']).'</strong> <br /> '.$text.'
<a href="#" title="Читати далі">&rarr;</a><br />
';
		}
		
		Template::getInstance()->set('{lastposts}',$all,'main');
	}
	public static function initAdminArea(){
		
	}
}